package com.long1008.controller.emp.dtreeprediction;

import com.long1008.pojo.DModel.TurnoverModelDto;
import com.long1008.pojo.Employee;
import com.long1008.pojo.Hr;
import com.long1008.pojo.RespBean;
import com.long1008.service.DTreeService;
import com.long1008.service.HrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/employee/resignation")
public class EmpResignationController {
    @Autowired
    DTreeService dTreeService;

    @RequestMapping("/{keywords}")
    public List<Employee> getEmpByKeywords(@PathVariable(required = false) String keywords) {
        List<Employee> employees = dTreeService.selectEmpByKeywordsToShow(keywords);
        return employees;
    }

    @RequestMapping("/emp/{EmpId}")
    public Map<String,Object> selectOneEmpDetail(@PathVariable Long EmpId){
        Map<String ,Object> empDetail = dTreeService.selectOneEmpDetail(EmpId);
        return empDetail;
    }

    @RequestMapping(value = "/projections",method = RequestMethod.POST)
    public RespBean turnoverProjections(TurnoverModelDto dto){
        Integer result = dTreeService.turnoverProjections(dto);
        if(result == 0){
            return RespBean.ok("预测结果为暂时不会离职");
        } else if (result == 1) {
            return RespBean.ok("预测结果为可能离职");
        }

        return RespBean.error("数据处理出错");
    }


}
